package com.ruoyi.system.Controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CmAbnormalInfo;
import com.ruoyi.system.service.ICmAbnormalInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 求助处理统计Controller
 * 
 * @author pop404NotFound
 * @date 2021-12-12
 */
@Controller
@RequestMapping("/CmSystem/CmAbnormalInfo")
public class CmAbnormalInfoController extends BaseController
{
    private String prefix = "CmSystem/CmAbnormalInfo";

    @Autowired
    private ICmAbnormalInfoService cmAbnormalInfoService;

    @RequiresPermissions("CmSystem:CmAbnormalInfo:view")
    @GetMapping()
    public String CmAbnormalInfo()
    {
        return prefix + "/CmAbnormalInfo";
    }

    /**
     * 查询求助处理统计列表
     */
    @RequiresPermissions("CmSystem:CmAbnormalInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CmAbnormalInfo cmAbnormalInfo)
    {
        startPage();
        List<CmAbnormalInfo> list = cmAbnormalInfoService.selectCmAbnormalInfoList(cmAbnormalInfo);
        return getDataTable(list);
    }

    /**
     * 导出求助处理统计列表
     */
    @RequiresPermissions("CmSystem:CmAbnormalInfo:export")
    @Log(title = "求助处理统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CmAbnormalInfo cmAbnormalInfo)
    {
        List<CmAbnormalInfo> list = cmAbnormalInfoService.selectCmAbnormalInfoList(cmAbnormalInfo);
        ExcelUtil<CmAbnormalInfo> util = new ExcelUtil<CmAbnormalInfo>(CmAbnormalInfo.class);
        return util.exportExcel(list, "求助处理统计数据");
    }

    /**
     * 新增求助处理统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存求助处理统计
     */
    @RequiresPermissions("CmSystem:CmAbnormalInfo:add")
    @Log(title = "求助处理统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CmAbnormalInfo cmAbnormalInfo)
    {
        return toAjax(cmAbnormalInfoService.insertCmAbnormalInfo(cmAbnormalInfo));
    }

    /**
     * 修改求助处理统计
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        CmAbnormalInfo cmAbnormalInfo = cmAbnormalInfoService.selectCmAbnormalInfoById(id);
        mmap.put("cmAbnormalInfo", cmAbnormalInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存求助处理统计
     */
    @RequiresPermissions("CmSystem:CmAbnormalInfo:edit")
    @Log(title = "求助处理统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CmAbnormalInfo cmAbnormalInfo)
    {
        return toAjax(cmAbnormalInfoService.updateCmAbnormalInfo(cmAbnormalInfo));
    }

    /**
     * 删除求助处理统计
     */
    @RequiresPermissions("CmSystem:CmAbnormalInfo:remove")
    @Log(title = "求助处理统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(cmAbnormalInfoService.deleteCmAbnormalInfoByIds(ids));
    }
}
